/*
 * @Description:
 * @Version: 2.0
 * @Autor: snzo.chen
 * @Date: 2021-09-16 09:47:01
 * @LastEditors: snzo.chen
 * @LastEditTime: 2021-09-16 10:51:52
 */
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { map, Observable } from 'rxjs';
import { AnyJson } from './data-types/common.type';
import { ServicesModule } from './services.module';

@Injectable({
  providedIn: ServicesModule,
})
export class ExchangeService {
  constructor(private http: HttpClient) {}

  getAll(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/meetActReview/getAll', body, { params })
      .pipe(map((res) => res as AnyJson));
  }

  getActiveByBid(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/meetActReview/getActiveByBid', body, { params })
      .pipe(map((res) => res as AnyJson));
  }

  getActivityMsgById(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/meetActReview/getActivityMsgById', { params })
      .pipe(map((res) => res as AnyJson));
  }

  addMeetActReview(body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/meetActReview/create', body)
      .pipe(map((res) => res as AnyJson));
  }

  updateActive(body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/meetActReview/updateActive', body)
      .pipe(map((res) => res as AnyJson));
  }

  likeActive(params: AnyJson, body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/meetActReview/likeActive', body, { params })
      .pipe(map((res) => res as AnyJson));
  }

  deleteActive(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/meetActReview/deleteActive', { params })
      .pipe(map((res) => res as AnyJson));
  }

  clearSort(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/meetActReview/clearSort', { params })
      .pipe(map((res) => res as AnyJson));
  }

  /*****图集管理*****/

  getAcRevPhColByBid(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/activePhoto/getAcRevPhColByBid', { params })
      .pipe(map((res) => res as AnyJson));
  }

  insertActivePhoto(body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/activePhoto/insertActivePhoto', body)
      .pipe(map((res) => res as AnyJson));
  }

  updateActiveReviewPhotoById(body: AnyJson): Observable<AnyJson> {
    return this.http
      .post('/activePhoto/updateActiveReviewPhotoById', body)
      .pipe(map((res) => res as AnyJson));
  }

  deleteActiveReviewPhotoById(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/activePhoto/deleteActiveReviewPhotoById', { params })
      .pipe(map((res) => res as AnyJson));
  }

  clearActivePhotoSort(params: AnyJson): Observable<AnyJson> {
    return this.http
      .get('/activePhoto/clearSort', { params })
      .pipe(map((res) => res as AnyJson));
  }
}
